<?php header("Content-type: application/javascript"); 
session_start();
?>

jQuery(document).ready(function($) {
	// pass in your custom templates on init
	$("#dp3").datepicker({
		"setDate" : new Date(),
		"autoclose" : true
	});
	$("#dp4").datepicker({
		"setDate" : new Date(),
		"autoclose" : true
	});
	$('.timepicker1').timepicker({
		showMeridian : false,
		disableFocus : false,
	});
	var d = new Date();

	var month = d.getMonth()+1;
	var day = d.getDate();
	
	var date_output = ((''+day).length<2 ? '0' : '') + day +'-'+
				 ((''+month).length<2 ? '0' : '') + month + '-' +
				 d.getFullYear();

	dataString = "date=" + date_output + "&b_user=" + <?php echo $_SESSION['USER_ID']; ?> + "&today=yes";
	$.ajax({
		type : "GET",
		url : "execute/show_results.php",
		data : dataString,
		success : function(data) {
			$("#show_appointments").html(data);
			$("#date_header").html(date_output);
		}
	});
	
	$("#date_picker").on("change",function(){
		$("#show_appointments").css("opacity","0.3");
		$("#date_header").hide();
		$("#ajax-loader").show();
		var date_output = $(this).val();
		dataString = "date=" + date_output + "&b_user=" + <?php echo $_SESSION['USER_ID']; ?> + "&today=yes";
	$.ajax({
		type : "GET",
		url : "execute/show_results.php",
		data : dataString,
		success : function(data) {
			$("#show_appointments").html(data);
			$("#ajax-loader").hide();
			$("#date_header").show();
			$("#show_appointments").css("opacity","1");
			$("#date_header").html(date_output);
		}
	});
	});
});// end jQuery


